import { createRouter, createWebHistory } from 'vue-router'
import { setupRouterGuards } from './guards'
import Layout from '@/views/Layout.vue'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/auth/Login.vue'),
      meta: { title: '登录' }
    },
    {
      path: '/',
      component: Layout,
      redirect: '/dashboard',
      children: [
        {
          path: '/dashboard',
          name: 'Dashboard',
          component: () => import('@/views/Dashboard.vue'),
          meta: { title: '仪表盘', icon: 'DataBoard' }
        },
        {
          path: '/media-library',
          name: 'MediaLibrary',
          component: () => import('@/views/MediaLibrary.vue'),
          meta: { title: '媒体库', icon: 'VideoCamera' }
        },
        {
          path: '/upload',
          name: 'Upload',
          component: () => import('@/views/Upload.vue'),
          meta: { title: '上传管理', icon: 'Upload' }
        },
        {
          path: '/categories',
          name: 'Categories',
          component: () => import('@/views/Categories.vue'),
          meta: { title: '分类管理', icon: 'Menu' }
        },
        {
          path: '/analytics',
          name: 'Analytics',
          component: () => import('@/views/Analytics.vue'),
          meta: { title: '数据分析', icon: 'TrendCharts' }
        },
        {
          path: '/settings',
          name: 'Settings',
          component: () => import('@/views/Settings.vue'),
          meta: { title: '系统设置', icon: 'Setting', requiresAdmin: true }
        }
      ]
    },
    {
      path: '/player/:id',
      name: 'Player',
      component: () => import('@/views/Player.vue'),
      meta: { title: '播放器' }
    }
  ]
})

// 设置路由守卫
setupRouterGuards(router)

export default router 